package consul

import (
	"9-13yk/common/naocs"
	"fmt"
	"github.com/google/uuid"
	"github.com/hashicorp/consul/api"
)

func Consul() {
	nac := naocs.Config.Consul
	consul, err := api.NewClient(&api.Config{Address: fmt.Sprintf("%s:%d", nac.Host, nac.Port)})
	s := uuid.New().String()
	err = consul.Agent().ServiceRegister(&api.AgentServiceRegistration{
		ID:      s,
		Name:    nac.Name,
		Port:    nac.Port,
		Address: nac.Host, // Replace with the actual address if necessary
		Tags:    []string{"GRPC"},
	})
	if err != nil {
		return
	}
}
